#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int isUnique(int *arr,const int length, const int value)
{
    for (int i = 0; i < length; i++)
    {
        if (arr[i] == value)
        {
            return 0;
        }
    }
    return 1;
}


int *mergeArray(const int *nums1, const int *nums2,int length1,int length2, int *result, int *result_length)
{
    int cnt = 0;
    for (int idx = 0; idx < length1; idx++)
    {
        if (isUnique(result, cnt, nums1[idx])==1)
        {
            result[cnt] = nums1[idx];
            cnt++;
        }
    }

    for (int jdx = 0; jdx < length2; jdx++)
    {
        if (isUnique(result, cnt, nums2[jdx])==1)
        {
            result[cnt] = nums2[jdx];
            cnt++;
        }
    }

    *result_length = cnt;
    return result;
}


int main()
{
    int *result = (int*)malloc(100*sizeof(char));
    memset(result,0,sizeof(char)*100);
    int result_length = 0;
    int nums1[100] = {1, 5, 234, 213, 11, 50};
    int nums2[100] = {1, 7, 9, 35, 357, 54, 50, 22};
    int length1 = sizeof(nums1) / sizeof(nums1[0]);
    int length2 = sizeof(nums2) / sizeof(nums2[0]);

    int *nums = mergeArray(nums1, nums2, length1, length2, result, &result_length);

    for (int i = 0; i < result_length; i++)
    {
        printf("%d ", nums[i]);
    }
    printf("\n");
    free(result);
    return 0;
}